home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / bash_completion.d / deborphan < prev    next >
Encoding:
Text File  |  2006-11-23  |  2.2 KB  |  70 lines

  1. have deborphan &&
  2. _deborphan()
  3. {
  4.  
  5.   local last_item_in_list
  6.   local cur=$2 prev=$3
  7.   local options='--help -h --version -v --status-file -f
  8.     --show-deps -d --show-priority -P --show-size -z
  9.     --show-section -s --no-show-section --nice-mode -n
  10.     --all-packages -a --libdevel --exclude -e --priority -p
  11.     --force-hold -H --find-config --add-keep -A --del-keep -R
  12.     --list-keep -L --zero-keep -Z --keep-file -k
  13.     --guess-perl --guess-python --guess-pike
  14.     --guess-ruby --guess-interpreters
  15.     --guess-section --guess-dev --guess-debug
  16.     --guess-common --guess-data --guess-doc --guess-dummy
  17.     --guess-all --guess-only
  18.     '
  19.  
  20.   COMPREPLY=()
  21.  
  22.   case "$prev" in
  23.     # previous option asks for a file
  24.     -@(-status-file|f|-keep-file|k))
  25.       _filedir
  26.       return 0
  27.       ;;
  28.     # previous option asks for a package or "-"
  29.     # if there's more than 1 package listed, use the default below
  30.     # for package completion
  31.     # could maybe use /var/lib/deborphan/keep for -R|--del-keep
  32.     # but tricky if -f|--status-file is given
  33.     -@(-add-keep|A|-del-keep|R))
  34.       COMPREPLY=( $( compgen -W "$( _comp_dpkg_installed_packages $cur ) -" -- $cur ) )
  35.       return 0
  36.       ;;
  37.     # previous option asks for a priority
  38.     -@(-priority|p))
  39.       COMPREPLY=( $( compgen -W '1 2 3 4 5 required important standard optional extra' -- $cur) )
  40.       return 0
  41.       ;;
  42.     # previous option asks for a commaseparated list of packages
  43.     -@(-exclude|e))
  44.       last_item_in_list="${cur##*,}"
  45.       list_before_item="${cur%$last_item_in_list}"
  46.       #add "," to the list and take care of already existing listed packages
  47.       COMPREPLY=(
  48.                   $(
  49.                    compgen -S "," -P "$list_before_item" -W "$( _comp_dpkg_installed_packages $last_item_in_list )"
  50.                   )
  51.                 )
  52.  
  53.       return 0
  54.       ;;
  55.   esac
  56.  
  57.   if [[ "$cur" == -* ]]; then
  58.     # return one of the possible options
  59.     COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  60.   else
  61.     # return matching installed packages
  62.     # (default and for -A or -R package lis
  63.     COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
  64.   fi
  65.  
  66.   return 0
  67. }
  68. [ -n "${have:-}" ] && complete -F _deborphan $filenames deborphan
  69.  
  70.